package com.zlp.dto.test;

import com.google.common.collect.Lists;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Classname LhSupplierCreateReq
 * @Description 力瀚创建订单请求参数
 * @Date 2022/10/8 14:18
 * @Created by ZouLiPing
 */
@Data
public class LhSupplierCreateReq implements Serializable {


    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 付款金额
     */
    private BigDecimal payAmount = BigDecimal.ZERO;

    /**
     * 用户姓名
     */
    private String userName;

    /**
     * 卡密接收手机号
     */
    private String userMobile;

    /**
     * 订单sku列表
     */
    private List<SkuList> skuList;


    @Data
    public static class SkuList {

        /**
         * SKU编码
         */
        private String skuNo;

        /**
         * 购买数量
         */
        private int num;
    }


    public static LhSupplierCreateReq conventObj(Object paramMap) {

        SupplierCouponCreateReq supplierCouponCreateReq = (SupplierCouponCreateReq) paramMap;
        LhSupplierCreateReq lhSupplierCreateReq = new LhSupplierCreateReq();
        lhSupplierCreateReq.setOrderNo(supplierCouponCreateReq.getCusOrderNo());
        lhSupplierCreateReq.setPayAmount(BigDecimal.ZERO);
        List<SupplierCouponCreateReq.CusSkuDetail> cusSkuList = supplierCouponCreateReq.getCusSkuList();
        List<SkuList> skuList = new ArrayList<>();
        for (SupplierCouponCreateReq.CusSkuDetail cusSkuDetail : cusSkuList) {
            SkuList sku = new SkuList();
            sku.setSkuNo(cusSkuDetail.getCusSkuNo());
            sku.setNum(cusSkuDetail.getSkuNum());
            skuList.add(sku);
        }
        lhSupplierCreateReq.setSkuList(skuList);
        return lhSupplierCreateReq;

    }
}
